<template>
<div class="distributor-application views-container">
    <div class="wlm-table">
        <div class="wlm-table-header">
            <el-form :model="tableFormatData.userTable.files" size="small" label-width="80px" class="retail-form" label-position="right">
                <el-form-item label="" class="filter">
                    <el-form-item label="类型：">
                        <el-select size="small" v-model="tableFormatData.userTable.files.method">
                            <el-option label="文本" value="1">
                            </el-option>
                            <el-option label="图文" value="2">
                            </el-option>
                            <el-option label="公众号模板消息" value="3">
                            </el-option>
                             <el-option label="短信消息" value="6">
                            </el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item label="消息标题：" class="search">
                        <el-input @keyup.enter.native="filesSerch" v-model="tableFormatData.userTable.files.content" placeholder="请输入消息标题" style="width:175px;"></el-input>
                    </el-form-item>
                </el-form-item>
                <el-form-item label="" class="filter-btns">
                    <el-button type="primary" @click="filesSerch">筛选</el-button>
                    <el-button type="text" @click="filesEmpty">清空筛选条件</el-button>
                </el-form-item>
            </el-form>
        </div>
        <div class="wlm-table-content">
            <el-table :ref="tableFormatData.userTable.key" :data="tableFormatData.userTable.tableData" @selection-change="handleSelectionChange" style="width: 100%">
                <!-- <el-table-column type="selection" width="55">
                </el-table-column> -->
                <el-table-column prop="date" label="用户信息">
                    <template slot-scope="scope">
                        <div class="wlm-table-logos flex-row">
                            <img class="logo " :src="scope.row.avatarUrl">
                            <div class="inner-text scale-grow">
                                <p class="ellipsis" style="width:150px;">{{scope.row.nickName}}</p>
                                <el-tooltip class="item" effect="dark" :content="sourceType[`${scope.row.source}`]" placement="top">
                                    <img height="20" width="20" :src="sourceImg[`${scope.row.source || '-'}`]" alt="">
                                </el-tooltip>
                            </div>
                        </div>
                    </template>
                </el-table-column>
                <el-table-column prop="name" label="消息内容">
                    <template slot-scope="scope">
                        <span>{{scope.row.content}}</span>
                    </template>
                </el-table-column>
                <el-table-column prop="name" label="推送方式">
                    <template slot-scope="scope">
                        <span v-show="scope.row.method=='1'">文本</span>
                        <span v-show="scope.row.method=='2'">图文</span>
                        <span v-show="scope.row.method=='3'">公众号模板消息</span>
                        <span v-show="scope.row.method=='4'">小程序卡片</span>
                        <span v-show="scope.row.method=='5'">图片</span>
                        <span v-show="scope.row.method=='6'">短信消息</span>
                    </template>
                </el-table-column>
                <el-table-column prop="name" label="推送状态">
                    <template slot-scope="scope">
                        <el-tag v-show="scope.row.status=='1'" type="success">成功</el-tag>
                        <el-tag v-show="scope.row.status=='2'" type="danger">失败</el-tag>
                    </template>
                </el-table-column>
                <el-table-column prop="name" label="发送时间">
                    <template slot-scope="scope">
                        <span>{{scope.row.send_time | parseTime('{y}-{m}-{d} {h}:{i}:{s}')}}</span>
                    </template>
                </el-table-column>
                <el-table-column prop="name" label="结束时间">
                    <template slot-scope="scope">
                        <span>{{scope.row.end_time | parseTime('{y}-{m}-{d} {h}:{i}:{s}')}}</span>
                    </template>
                </el-table-column>
                <el-table-column prop="name" label="状态码">
                    <template slot-scope="scope">
                        <span>{{scope.row.code}}</span>
                    </template>
                </el-table-column>
                <!-- <el-table-column label="操作">
                    <template slot-scope="scope">
                        <div class="operation-group">
                            <el-button class="wlm-text" type="text" @click="delTableItem(scope.row.id)">删除</el-button>
                        </div>
                    </template>
                </el-table-column> -->
            </el-table>
            <div class="pagination-content flex-row flex-justify-b flex-align-c">
                <el-row class="pagination-btns">
                    <!-- <el-checkbox class="check-all" true-label="1" false-label="0" v-model="tableFormatData.userTable.files.checkall" @change="toggleSelection">全部</el-checkbox>
                    <el-button class="right-8" :disabled="isGroup" size="mini" @click="delTableList">删除</el-button> -->
                </el-row>
                <el-pagination :disabled="!hasTableData" @size-change="listPageChange" @current-change="listPageChange" :current-page.sync="tableFormatData.userTable.pagination.page" :page-sizes="tableFormatData.userTable.pagination.pagesizes" :page-size.sync="tableFormatData.userTable.pagination.list_rows" layout="total, sizes, prev, pager, next, jumper" :total="hasTableData?tableFormatData.userTable.pagination.total : 0">
                </el-pagination>
            </div>
        </div>
    </div>
</div>
</template>

<script>
import {
  applyCheck,
  applyStatistics,
  applyDelete
} from '@/api/distribution'
import {
  messageIndex
} from '@/api/application'
import mixins from '@/mixins/mixins'
export default {
  mixins: [mixins.getters('Table'), mixins.getters('Form')],
  name: 'DistributorApplication',
  components: {
  },
  created() {
    applyStatistics().then((response) => {
      const {
        data: {
          data: msgData = []
        }
      } = response
      this.categoryData = msgData
      console.log(this.categoryData)
    })
  },
  data() {
    return {
      categoryData: {},
      openDialogText: '',
      tableFormatData: {
        current: 'userTable',
        userTable: {
          key: 'userTable',
          api: {
            getList: messageIndex,
            delList: applyDelete
          },
          tableData: [],
          files: {
            content: '',
            method: '',
            ids: [],
            checkall: '0',
            Recycle: '1'
          },
          pagination: {
            page: 1,
            list_rows: 10,
            pagesizes: [10, 20, 50],
            total: 0
          }
        }
      },
      formFormatData: {
        key: 'userForm',
        model: {
          noCreateEdit: false
        },
        api: {
          editForm: {
            api: applyCheck,
            params: {
              id: ''
            }
          },
          submitForm: applyCheck
        },
        formData: {
          ids: [],
          content: '',
          status: '20'
        },
        rules: {

        }
      }
    }
  },
  methods: {
  }
}
</script>
